package com.roadjava.log.jul.demo2;

import java.util.logging.ConsoleHandler;
import java.util.logging.Logger;

public class JulService2 {

    public static void main(String[] args) {
        Logger logger1 = Logger.getLogger("a");
        // LogManager$RootLogger
        System.out.println(logger1.getParent());

        Logger logger2 = Logger.getLogger("a.b");
        // a
        System.out.println(logger2.getParent().getName());
        // true
        System.out.println(logger1 == logger2.getParent());

        Logger logger3 = Logger.getLogger("a.b.c");
        // a.b
        System.out.println(logger3.getParent().getName());
        // true
        System.out.println(logger2 == logger3.getParent());

        System.out.println("============");

        ConsoleHandler selfHandler = new ConsoleHandler();
        logger3.addHandler(selfHandler);
        // 避免重复输出
        logger3.setUseParentHandlers(false);
        logger3.info("hello");
    }

}
